home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1849 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  56 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: techfak.uni-bielefeld.de!isthesin
  3. From: isthesin@techfak.uni-bielefeld.de (Stephan Thesing)
  4. Subject: Re: Must I free my linked lists? (GCC)
  5. Message-ID: <DLoIKE.I29@hermes.hrz.uni-bielefeld.de>
  6. Sender: isthesin@TechFak.Uni-Bielefeld.DE (Stephan Thesing)
  7. Date: Wed, 24 Jan 1996 09:33:49 GMT
  8. References: <4dudic$aif@vixen.cso.uiuc.edu> <4dusp9$7k3@senator-bedfellow.MIT.EDU>
  9. Nntp-Posting-Host: moos.techfak.uni-bielefeld.de
  10. Organization: Universitaet Bielefeld, Technische Fakultaet.
  11. X-Newsreader: xrn 8.01
  12.  
  13. In article <4dusp9$7k3@senator-bedfellow.MIT.EDU>, rid@red-branch.MIT.EDU (Shawna Grimm) writes:
  14. |> Unknown (Dannyman@uiuc.edu) typed in the following on 21 Jan 1996 22:09:16 GMT:
  15. |> :    I'm writing a program that makes use of dynamic memory allocation through
  16. |> : linked lists using malloc() ... from an implementation PoV there's no need
  17. |> : to flush this stuff as after the queue is created it's output and the
  18. |> : program exits. My question is;
  19. |> 
  20. |> :    "When my program exits, is the dynamic memory in the queues returned to
  21. |> : the system or is a "memory hole" left, so that I should actually go back and
  22. |> : return all the memory in my program ..."
  23. |> 
  24. |> Yes, you _should_ free any memory that you allocate in your program. 
  25. |> Memory that is allocated and not freed will not be returned to the system 
  26. |> unless you turn the machine off, so if you want your memory back, you 
  27. |> must free it. Personally, I would prefer to use AllocMem() or AllocVec()
  28. |> (with FreeMem() and FreeVec() ofcourse).
  29. |> 
  30.  
  31. This is true, but normally memory allocated via malloc() is freed automatically
  32. by the exit code of the program.
  33. malloc() and free() differ from AllocMem()/FreeMem() (AllocVec()...) in this point.
  34. The startup (and exit) code that is linked in with gcc (crt0.o) does the
  35. necessary cleanup at exit (in conjunction with ixemul.library).
  36. Bye... 
  37.     Stephan
  38.  
  39.  
  40.  
  41.  
  42.  
  43. |> :    Thanks. Please reply publically, because I got 20 emails on my last
  44. |> : question. No *need* for all you courteous folk to respond! :)
  45. |> 
  46. |> : -- 
  47. |> * Lars M. Hansen              
  48.  
  49. -- 
  50. ===============================================
  51. =             Stephan Thesing                 =
  52. =        AG Praktische Informatik             =
  53. =          Technische Fakult"at               =
  54. =         Universit"at Bielefeld              =
  55. ===============================================
  56.